namespace ZFramework
{
    public class VoxelModel(int width, int height, int length)
    {
        private readonly Palette<Rgba32> _voxels = new(width, height, length);
        public AABBI BoundingBox { get; private set; } = new(0, 0, 0, width, height, length);

        public int Width => _voxels.Width;
        public int Height => _voxels.Height;
        public int Length => _voxels.Length;

        public void SetColor(int x, int y, int z, Rgba32 color)
        {
            if (_voxels.ContainsPoint(x, y, z))
            {
                _voxels[x, y, z] = color;
            }
        }

        public void RemoveAt(int x, int y, int z)
        {
            if (_voxels.ContainsPoint(x, y, z))
            {
                _voxels.Remove(x, y, z);
            }
        }

        public bool HasVoxel(int x, int y, int z) => _voxels.HasValue(x, y, z);

        public Rgba32 ColorAt(int x, int y, int z) => _voxels[x, y, z];
    }
}